package cn.maihe.elg.operation.centers.epoint.exception;

import cn.maihe.elg.operation.centers.epoint.enums.EpointRespCodeEnum;

/**
 * @Description
 * @Author WJH
 * @Date 2021/04/22
 */
public class EpointException extends RuntimeException {

    private EpointRespCodeEnum statusEnum;
    private String message;

    public EpointException(EpointRespCodeEnum statusEnum, String message, Throwable cause) {
        super(message, cause);
        this.statusEnum = statusEnum;
        this.message = message;
    }

    public static EpointException of(EpointRespCodeEnum statusEnum, String message) {
        return new EpointException(statusEnum, message, null);
    }

    public static EpointException of(EpointRespCodeEnum statusEnum, String message, Throwable cause) {
        return new EpointException(statusEnum, message, cause);
    }

    public static EpointException error(String message,Throwable... cause) {
        return new EpointException(EpointRespCodeEnum.FAILURE, message, cause!=null&&cause.length>0?cause[0]:null);
    }

    public EpointRespCodeEnum getStatusEnum() {
        return statusEnum;
    }

    @Override
    public String getMessage() {
        return message;

    }

}
